<template>
  <view style="margin: 12px;">
  		<uni-forms :modelValue="employee">
  			<uni-forms-item style="margin-bottom: 16px;margin-left: 28px;" label-align="center" label-width="100" label="姓名:" name="name">
  				<uni-easyinput type="text" v-model="employee.name" placeholder="请输入姓名" />
  			</uni-forms-item>
			<uni-forms-item style="margin-bottom: 16px;margin-left: 28px;" label-align="center" label-width="100" label="账号:" name="age">
				<uni-easyinput type="text" v-model="employee.account" placeholder="请输入账号" />
			</uni-forms-item>
			<uni-forms-item style="margin-bottom: 16px;margin-left: 28px;" label-align="center" label-width="100" label="密码:" name="age">
				<uni-easyinput type="text" v-model="employee.powhg" placeholder="请输入密码" />
			</uni-forms-item>
  			<uni-forms-item style="margin-bottom: 16px;margin-left: 28px;" label-align="center" label-width="100" label="年龄:" name="age">
  				<uni-easyinput type="text" v-model="employee.gender" placeholder="请输入年龄" />
  			</uni-forms-item>
  			<uni-forms-item style="margin-bottom: 16px;" label-align="center" label-width="100" label="出生日期:" name="hobby">
  				<uni-datetime-picker type="date" :clear-icon="false" v-model="employee.birthDate" @maskClick="maskClick" />
  			</uni-forms-item>
			<uni-forms-item style="margin-bottom: 16px;margin-left: 14px;" label-align="center" label-width="100" label="身份证:" name="age">
				<uni-easyinput type="text" v-model="employee.idCardNumber" placeholder="请输入身份证号码" />
			</uni-forms-item>
			<uni-forms-item style="margin-bottom: 16px;" label-align="center" label-width="100" label="联系电话:" name="hobby">
				<uni-easyinput type="text" v-model="employee.phoneNumber" placeholder="请输入电话号码" />
			</uni-forms-item>
			<uni-forms-item style="margin-bottom: 16px;margin-left: 28px;" label-align="center" label-width="100" label="邮箱:" name="hobby">
				<uni-easyinput type="text" v-model="employee.email" placeholder="请输入电子邮箱" />
			</uni-forms-item>
			<uni-forms-item style="margin-bottom: 16px;" label-align="center" label-width="100" label="家庭地址:" name="hobby">
				<uni-easyinput type="text" v-model="employee.address" placeholder="请输入家庭地址" />
			</uni-forms-item>
			<uni-forms-item style="margin-bottom: 16px;" label-align="center" label-width="100" label="紧急联系人:" name="hobby">
				<uni-easyinput type="text" v-model="employee.emergencyContact" placeholder="请输入紧急联系人" />
			</uni-forms-item>
			<uni-forms-item style="margin-bottom: 16px;" label-align="center" label-width="100" label="入职日期:" name="hobby">
				<uni-datetime-picker type="date" :clear-icon="false" v-model="employee.hireDate" @maskClick="maskClick" />
			</uni-forms-item>
			<uni-forms-item style="margin-bottom: 16px;margin-left: 28px;" label-align="center" label-width="100" label="岗位:" name="age">
				<uni-easyinput type="text" v-model="employee.position" placeholder="请输入岗位" />
			</uni-forms-item>
			<uni-forms-item style="margin-bottom: 16px;margin-left: 28px;" label-align="center" label-width="100" label="备注:" name="age">
				<uni-easyinput type="textarea" v-model="employee.remark" placeholder="请输入备注" />
			</uni-forms-item>
  		</uni-forms>
		<view style="display: flex;">
			<button style="width: calc(50% - 24px);margin: 12px;" type="danger" @click="czan">重置</button>
			<button style="width: calc(50% - 24px);margin: 12px;" type="primary" @click="submitForm">添加</button>
		</view>
		<uni-popup ref="popup" type="message">
			<uni-popup-message type="success" message="添加成功" :duration="2000"></uni-popup-message>
		</uni-popup>
  	</view>
</template>

<script>
	import {
		Add_employ
	} from "@/pages/apis/login.js"
export default {
  data() {
    return {
      employee: {
        name: '',
		account:'',
		powhg:'',
		gender:'',
		birthDate:'',
		idCardNumber:'',
		phoneNumber:'',
		email:'',
		address:'',
		emergencyContact:'',
		position:'',
		hireDate:'',
        remark: ''
      },
    };
  },
  methods: {
    async submitForm() {
	  const res = await Add_employ(this.employee);
	  if(res.code===0){
		  this.$refs.popup.open();
	  	setTimeout(() => {
			this.$router.go(-1);
	  	 }, 2000);
	  }
    },
    czan() {
		this.$refs.popup.open();
    }
  }
};
</script>

<style scoped>
</style>